home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 5
/
The 640 Meg Shareware Studio CD-ROM Volume V (Data Express)(1994).ISO
/
amiga
/
tempdemo.lha
/
ProgrammersInfo
/
DSKEL-WHOg.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-22
|
6KB
|
257 lines
/*
.----------------------------------------------------------------.
| NODE | LOGON | HANDLE | ACTIVITY |
|======|=======|===========================|=====================|
| 1 | 17:45 | The Skeleton | Downloading |
|------|-------|---------------------------|---------------------|
| 2 | --:-- | Awaiting a call | Idle |
|------|-------|---------------------------|---------------------|
| 3 | --:-- | Awaiting a call | Idle |
`----------------------------------------------------------------'
*/
//**********************
//***** Includes *****
//**********************
#include <proto/all.h>
#include <stdio.h>
#include <exec/memory.h>
#include <string.h>
#include <tempest/headers.h>
//********************************
//***** Structures/Defines *****
//********************************
struct MyMessage
{
struct Message Msg;
struct User User;
char text[255],
text1[255];
int car,Value,Data;
long LongValue;
int IntValue;
};
struct User User;
struct MsgPort *MyPort = NULL;
struct MyMessage *msg;
struct node_info nody;
void CloseStuff();
int DOORIO();
int Loadnody(int node);
//******************************
//***** Global Variables *****
//******************************
int EXIT_FLAG, DOOR_DATA, DOOR_CAR, DOOR_VALUE, DOOR_VALUE1 = 0,
Result,Error,first = 0,NODE;
char MyName[255],st[100],DOOR_MSG[255],DOOR_MSG1[255],nodename[255];
//*****************************
//***** PL (Print Line) *****
//*****************************
void pl(fmt,a1,a2,a3,a4)
char *fmt;
{
char s[255];
sprintf(s,fmt,a1,a2,a3,a4);
DOOR_DATA=1; strcpy(DOOR_MSG,s); DOORIO();
}
//******************
//***** Main *****
//******************
void main(int argc,char *argv[])
{
char string[200],string2[20];
char Handle[40],Activity[30],Time[15];
register int i;
int NODES,stat;
if(!DoorStart(argv[1])) { PutStr("[os2] Tempest Door\n"); exit(0); }
if(!User.NFlags1 & NF1_ViewNodeLists) CloseStuff();
//***************************
//***** Load nodeinfo *****
//***************************
NODE = atoi(argv[1]);
stat=Loadnody(NODE);
if(stat==0)
{
pl("NodeInfo File Not Found!\r\n");
CloseStuff();
}
NODES = nody.SystemDataInfo->NumberOfLines + 1;
pl("\r\n\r\n
.----------------------------------------------------------------.
\r\n");
pl("
|
NODE
|
LoGoN
|
HANDLE
|
ACTiViTY
|\r\n");
//***************************
//***** Who is Online *****
//***************************
i=1;
do
{
if(CTRLC())
{
pl("
Aborting Who Display!
\r\n");
CloseStuff();
}
stat=Loadnody(i);
if(stat==0) setmem(&nody,sizeof(struct node_info),NULL);
strcpy(Handle,nody.UserInfo->Name);
if((*nody.hide==1)&&(User.Security!=255)&&(User.Name[0]!=NULL))
{
if(nody.UserInfo->Slot_Number==1) Handle[0]=NULL;
else strcpy(Handle,"[ Hiding From Display ]");
}
if(Handle[0]!=NULL)
{
sprintf(string,"%s",ctime(&nody.UserInfo->Time_Last_Connect));
strmid(string,Time,12,5);
strcpy(Activity,nody.activity);
sprintf(string,"NODE:CHAT-%d",i);
if(access(string,0)==0) strcpy(Activity,"Chat System");
//**************************
//***** Final Output *****
//**************************
pl(" |------|-------|---------------------------|---------------------|\r\n");
if(nody.NodeDataInfo->LocalMode==0) sprintf(string2,"%2d",i);
else strcpy(string2," V");
pl(" |
%2s
|
%5s
|
%-25.25s
|
%-19s
|\r\n",
string2,Time,Handle,Activity);
}
i++;
}
while(i<NODES);
pl(" `----------------------------------------------------------------'\r\n\r\n");
CloseStuff();
}
//************************
//***** Load Nody ******
//************************
int Loadnody(int node)
{
char string[50];
register int y;
int file;
sprintf(string,"Node:NodeInfo_%d",node);
for(y=1;y<3;y++)
{
file=Open(string,MODE_OLDFILE);
if(file!=0)
{
Read(file,(char *)&nody,sizeof(struct node_info));
Close(file);
return(1);
}
}
return(0);
}
//*************************
//***** Close Stuff *****
//*************************
void CloseStuff()
{ DOOR_DATA=99; strcpy(DOOR_MSG,'\0'); DOORIO();
while(msg=(struct MyMessage *)GetMsg(MyPort)) ReplyMsg((struct Message *)msg);
if(MyPort) DeletePort(MyPort);
exit(0); }
//********************
//***** DoorIO *****
//********************
int DOORIO()
{
struct MsgPort *HisPort;
struct MyMessage message;
int UPDATE;
if(EXIT_FLAG) return 0;
UPDATE=0;
HisPort = FindPort(st);
if(HisPort!=NULL)
{
message.Msg.mn_Node.ln_Type = NT_MESSAGE;
message.Msg.mn_Length = sizeof(message);
message.Msg.mn_ReplyPort = MyPort;
if(first)CopyMem(&User,&message.User,sizeof(struct User));
message.car = 0;
message.Data = DOOR_DATA;
message.Value = DOOR_VALUE;
message.IntValue = DOOR_VALUE1;
strcpy(message.text,DOOR_MSG);
strcpy(message.text1,DOOR_MSG1);
PutMsg((struct MsgPort *)HisPort,(struct Message *)&message);
Wait(1 << MyPort->mp_SigBit);
GetMsg(MyPort);
DOOR_DATA = message.Data;
DOOR_VALUE = message.Value;
DOOR_VALUE1 = message.IntValue;
strcpy(DOOR_MSG,message.text);
strcpy(DOOR_MSG1,message.text1);
CopyMem(&message.User,&User,sizeof(struct User));
first=1;
UPDATE=0;
if(message.car) EXIT_FLAG=1;
}
return(0);
}
//************************
//***** Door Start *****
//************************
DoorStart(char node[])
{
struct MsgPort *HisPort;
EXIT_FLAG = 0;
sprintf(st,"%s:TEMPEST_DOOR",node);
HisPort = FindPort(st);
if(HisPort==NULL) return (FALSE);
sprintf(MyName,"%s:DOOR_PORT",node);
MyPort = CreatePort(MyName,0L);
if(MyPort==NULL)
{
PutStr("Cant open port");
return(int)FALSE;
}
DOORIO();
return (int)TRUE;
}
//*************************
//***** CTRLC CHECK *****
//*************************
int CTRLC(void)
{
DOOR_DATA=73;
DOORIO();
return(DOOR_VALUE);
}